$(function () {
    let form = layui.form;
    let layer = layui.layer;

    form.verify({

        pass: [
            /^[\S]{6,12}$/
            ,'密码必须6到12位，且不能出现空格'
          ] ,
        //判断两次密码是否一致
        pwdss: function (value) {
            let content = $('[name=password]').val()
            if (value !== content) {
                return '两次输入的密码不一样'
            }
        }
    });


    //给form表单注册提交事件
    $(".layui-form").on("submit",function (e) {
        // console.log(123)
        e.preventDefault();
        let data = $(this).serialize();
        // console.log(data)
     
        $.ajax({
            url: "admin/users",
            type: "POST",
            data,
            success: function (res) {
                console.log(res);
                if (res.status !== 0) {
                    return layer.msg(res.message);
                  }
          
                  layer.msg(res.message);
            }
        })

    })
    })